import "LotroLCD.LotroLCD";

--Turbine.Shell.WriteLine("debug");

--Run LotroLCD
lotroLCD = LotroLCD();

-- Command Line Interface
LotroLCDCLI = class(Turbine.ShellCommand);

-- Handle each parameter that can be passed via command line
function LotroLCDCLI:Execute(command, arguments)
	if arguments == "reset" then
		Turbine.Shell.WriteLine("Resetting LotroLCD settings and unloading the plugin");
		lotroLCD.settings.windows = lotroLCD:GetDefaultWindowSettings();
		lotroLCD:SaveSettings();
		Turbine.PluginManager.UnloadScriptState("LotroLCD");
		Turbine.Shell.WriteLine("Please reload the plugin for the changes to take effect");
		Turbine.Shell.WriteLine("To reload the plugin use /plugins unload AND /plugins load lotrolcd ");
	
	elseif arguments == "help" then
		Turbine.Shell.WriteLine("LotroLCD Command Line Interface");
		Turbine.Shell.WriteLine("Supported parameters:");
		Turbine.Shell.WriteLine("    help - Shows this help message");
		Turbine.Shell.WriteLine("    reset - Resets window config to default");
	else
		Turbine.Shell.WriteLine("Invalid parameter!");
		Turbine.Shell.WriteLine(LotroLCDCLI:GetShortHelp());
	end
end

-- Help function, shows command line help
function LotroLCDCLI:GetShortHelp()
	return "Usage: /lotrolcd reset|help";
end

lotroLCDCLI = LotroLCDCLI();
Turbine.Shell.AddCommand('lotrolcd', lotroLCDCLI);

-- Write help info
Turbine.Shell.WriteLine ("Command line interface available, Usage: /lotrolcd help");